import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int q=sc.nextInt();
        int[] a=new int[n+1];
        for(int i=1;i<=n;i++){
            a[i]=sc.nextInt();
        }
        long[] dp=new long[n+1];
        for(int i=1;i<=n;i++){
            dp[i]=dp[i-1]+a[i];
        }
        while(q-->0){
            int l=sc.nextInt();
            int r=sc.nextInt();
            System.out.println(dp[r]-dp[l-1]);
        }
    }
}